//
//  IOSViewController.m
//  ios11-1
//
//  Created by mac on 15-11-9.
//  Copyright (c) 2015年 Lee. All rights reserved.
//

#import "IOSViewController.h"
#import "ViewController.h"
@interface IOSViewController ()
{
    NSArray * date;
    NSArray * number;
}
@end

@implementation IOSViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return date.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell * cell1 = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleSubtitle reuseIdentifier:nil];
    cell1.textLabel.text = date[indexPath.row];
    cell1.detailTextLabel.text = number[indexPath.row];
    cell1.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
    return cell1;
}



- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    date = @[
                @"我爱你",
                @"我不爱你",
                @"我讨厌你",
                @"我喜欢你",
                @"我不喜欢你"
             ];
    number = @[
                @"1",
                @"2",
                @"3",
                @"4",
                @"5"
               ];
    self.title = @"第二控制器";
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    ViewController * con = [ViewController new];
    [self.navigationController pushViewController:con animated:YES];
}

- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath{
    return YES;
}

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath{
    
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        NSMutableArray * arr = date.mutableCopy;
        [arr removeObjectAtIndex:indexPath.row];
        date = arr;
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationTop];
    }
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
